<template>
  <div class="order-container">
    <div class="hd">
      <el-form :model="orderForm" inline>
        <el-form-item>
          <el-input
            v-model="orderForm.name"
            placeholder="输入订单名称"
            size="mini"
            style="width: 200px; margin-right: 20px"
          />
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-search
"
            @click="search"
            >搜索</el-button
          >
          <el-button
            type="warning"
            size="mini"
            icon="el-icon-refresh-left

"
            @click="reset"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格区域 -->
    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%; height: 650px; overflow-y: auto"
    >
      <el-table-column label="课程名称" prop="title" />
      <el-table-column prop="intro" label="课程简介" />
      <el-table-column prop="price" label="课程价格" />
      <el-table-column prop="courseTime" label="课程时长(分钟)" />
      <el-table-column prop="status" label="课程类型">
        <template slot-scope="scope">
          <el-tag type="success" size="mini" v-if="scope.row.status === 0"
            >免费</el-tag
          >
          <el-tag type="warning" size="mini" v-else>付费</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="author" label="授课老师" />
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="mini" @click="edit(scope.row.id)"
            >编辑</el-button
          >
          <el-button type="text" size="mini" @click="del(scope.row.id)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination
      :total="total"
      :page.sync="currentPage"
      :limit.sync="page"
      @pagination="getOrderList"
    />
  </div>
</template>

<script>
import { order } from "@/api/order";
export default {
  data() {
    return {
      orderForm: {},
      total: 0,
      // 当前页
      currentPage: 1,
      // 每页多少条
      page: 20,
      tableData: [],
    };
  },
  methods: {
    getOrderList() {
      order({
        size: this.page,
        current: this.currentPage,
      }).then((res) => {
        console.log(res);
      });
    },
  },
  created() {
    this.getOrderList();
  },
};
</script>

<style lang="scss" scoped>
.order-container {
  height: 100%;
  padding: 20px 40px;
  .hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
</style>
